//
//  SourceViewCell.m
//  zhijian
//
//  Created by lcb on 2019/4/6.
//  Copyright © 2019 lcb. All rights reserved.
//

#import "SourceViewCell.h"
#import "SourceModel.h"
@interface SourceViewCell ()
@property (strong, nonatomic) UIView *sourceView;
@property (strong, nonatomic) UILabel *cateKey;
@property (strong, nonatomic) UILabel *cateVal;
@property (strong, nonatomic) UILabel *casKey;
@property (strong, nonatomic) UILabel *casVal;
@property (strong, nonatomic) UILabel *cnameKey;
@property (strong, nonatomic) UILabel *cnameVal;
@property (strong, nonatomic) UILabel *enameKey;
@property (strong, nonatomic) UILabel *enameVal;
@property (strong, nonatomic) UILabel *sortKey;
@property (strong, nonatomic) UILabel *sortVal;
@end

@implementation SourceViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 设置约束
        self.backgroundColor=[UIColor clearColor];
        [self setup];
    }
    return self;
}
-(void)setup {
    _sourceView = [[UIView alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-40, 180)];
    _sourceView.backgroundColor=[UIColor whiteColor];
    _sourceView.layer.cornerRadius=20;
    _sourceView.layer.masksToBounds = YES;
    [self addSubview:_sourceView];
    //
    _cateKey = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 80, 20)];
    _cateKey.font = [UIFont systemFontOfSize:14];
    _cateKey.textColor=UIColorOfHex(0x333333);
    _cateKey.text =@"类别:";
    [_sourceView addSubview:_cateKey];
    _cateVal = [[UILabel alloc] initWithFrame:CGRectMake(_cateKey.frame.origin.x+_cateKey.frame.size.width,_cateKey.frame.origin.y, SCREEN_WIDTH/2, 20)];
    _cateVal.font = [UIFont systemFontOfSize:14];
    _cateVal.textColor=UIColorOfHex(0x333333);
    _cateVal.textAlignment = NSTextAlignmentLeft;
    [_sourceView addSubview:_cateVal];
    //
    _casKey = [[UILabel alloc] initWithFrame:CGRectMake(10, _cateKey.frame.origin.y+_cateKey.frame.size.height+10, 70, 20)];
    _casKey.font = [UIFont systemFontOfSize:14];
    _casKey.textColor=UIColorOfHex(0x333333);
    _casKey.text =@"CAS号:";
    [_sourceView addSubview:_casKey];
    _casVal = [[UILabel alloc] initWithFrame:CGRectMake(_casKey.frame.origin.x+_casKey.frame.size.width,_casKey.frame.origin.y, _sourceView.frame.size.width-100, 20)];
    _casVal.font = [UIFont systemFontOfSize:14];
    _casVal.textColor=UIColorOfHex(0x333333);
    _casVal.textAlignment = NSTextAlignmentLeft;
    [_sourceView addSubview:_casVal];
    //
    _cnameKey = [[UILabel alloc] initWithFrame:CGRectMake(10, _casKey.frame.origin.y+_casKey.frame.size.height+10, 70, 20)];
    _cnameKey.font = [UIFont systemFontOfSize:14];
    _cnameKey.textColor=UIColorOfHex(0x333333);
    _cnameKey.text =@"中文名:";
    [_sourceView addSubview:_cnameKey];
    _cnameVal = [[UILabel alloc] initWithFrame:CGRectMake(_cnameKey.frame.origin.x+_cnameKey.frame.size.width,_cnameKey.frame.origin.y, _sourceView.frame.size.width-100, 20)];
    _cnameVal.font = [UIFont systemFontOfSize:14];
    _cnameVal.textColor=UIColorOfHex(0x333333);
    _cnameVal.textAlignment = NSTextAlignmentLeft;
    [_sourceView addSubview:_cnameVal];
    //
    _enameKey = [[UILabel alloc] initWithFrame:CGRectMake(10, _cnameKey.frame.origin.y+_cnameKey.frame.size.height+10, 70, 20)];
    _enameKey.font = [UIFont systemFontOfSize:14];
    _enameKey.textColor=UIColorOfHex(0x333333);
    _enameKey.text =@"英文名:";
    [_sourceView addSubview:_enameKey];
    _enameVal = [[UILabel alloc] initWithFrame:CGRectMake(_enameKey.frame.origin.x+_enameKey.frame.size.width,_enameKey.frame.origin.y, _sourceView.frame.size.width-100, 20)];
    _enameVal.font = [UIFont systemFontOfSize:14];
    _enameVal.textColor=UIColorOfHex(0x333333);
    _enameVal.textAlignment = NSTextAlignmentLeft;
    [_sourceView addSubview:_enameVal];
    //
    _sortKey = [[UILabel alloc] initWithFrame:CGRectMake(10, _enameKey.frame.origin.y+_enameKey.frame.size.height+10, 70, 20)];
    _sortKey.font = [UIFont systemFontOfSize:14];
    _sortKey.textColor=UIColorOfHex(0x333333);
    _sortKey.text =@"序号:";
    [_sourceView addSubview:_sortKey];
    _sortVal = [[UILabel alloc] initWithFrame:CGRectMake(_sortKey.frame.origin.x+_sortKey.frame.size.width,_sortKey.frame.origin.y, _sourceView.frame.size.width-100, 20)];
    _sortVal.font = [UIFont systemFontOfSize:14];
    _sortVal.textColor=UIColorOfHex(0x333333);
    _sortVal.textAlignment = NSTextAlignmentLeft;
    [_sourceView addSubview:_sortVal];
    //
}
-(void)dealloc
{
    
}
-(void)setBaseModel:(BaseModel *)baseModel
{
    SourceModel*qModel = (SourceModel*)baseModel;
    self.cateKey.text =@"类别:";
    self.cateVal.text = [[BaseShare sharedBaseShare] cate:qModel.kinds];
    //
    if (qModel.kinds>=6) {
        self.casKey.text =@"CI号:";
        self.casVal.text = qModel.sourceCi;
    }else{
        self.casKey.text =@"CAS号:";
        self.casVal.text = qModel.sourceCas;
    }
    //
    self.cnameKey.text =@"中文名:";
    self.cnameVal.text = qModel.chinaName;
    //
    self.enameKey.text =@"英文名:";
    self.enameVal.text = qModel.englishName;
    //
    self.sortKey.text =@"序号:";
    if (qModel.kinds>=6) {
        self.sortVal.text = [NSString stringWithFormat:@"%@(中国)-%@(韩国)",qModel.chinaId,qModel.uid];
    }else{
        self.sortVal.text = [NSString stringWithFormat:@"%@(中国)-%@(欧盟)",qModel.chinaId,qModel.uid];
    }
}

@end
